using UnityEngine;
using System.Collections;

public class PlayerPowerups : MonoBehaviour {

    public AudioClip powerupSoundThrob;
	public AudioClip powerupSoundBeet;
	public AudioClip powerupSoundSole;

    public enum PowerupNames
    {
        None,
        HeartSole,
        HeartThrob,
        HeartBeet
    };
    public PowerupNames powerup;
    private float timeLeft = 0.0f;

	// Use this for initialization
	void Start () {
        powerup = PowerupNames.None;
	}
	
	// Update is called once per frame
	void Update () {
        if (powerup != PowerupNames.None)
        {
            timeLeft -= Time.deltaTime;
            if (timeLeft <= 0.0f)
            {
                SetPowerUp(PowerupNames.None, 0.0f);
            }
        }
	}

    public void SetPowerUp(PowerupNames pu, float time)
    {
        powerup = pu;
        timeLeft = time;

        switch (pu)
        {
            case PowerupNames.HeartBeet:
				audio.PlayOneShot(powerupSoundBeet);
                renderer.material = Resources.Load("heroBeetMaterial") as Material;
                break;
            case PowerupNames.HeartSole:
				audio.PlayOneShot(powerupSoundSole);
                renderer.material = Resources.Load("heroSoleMaterial") as Material;
                break;
            case PowerupNames.HeartThrob:
				audio.PlayOneShot(powerupSoundThrob);
                renderer.material = Resources.Load("heroHeartthrobMaterial") as Material;
                break;
            case PowerupNames.None:
                if(GlobalState.isRedHero)
                    renderer.material = Resources.Load("heroMaterial") as Material;
                else
                    renderer.material = Resources.Load("blackheartMaterial") as Material;
                break;

        }
    }

}
